package com.study.controller;

import com.study.dto.Role;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.UUID;

/**
 * @author chenyeqing
 * @date 2021/11/25 22:27
 */
@Api(value = "角色控制器", tags = "角色管理")
@RestController
public class RoleController {

    @ApiResponses(
            {
                    @ApiResponse(code = 200, message = "请求成功"),
                    @ApiResponse(code = 500, message = "系统错误", response = Exception.class),
                    @ApiResponse(code = 600, message = "可以退费")
            }
    )
    @ApiOperation("查询角色")
    @PostMapping("/show")
    public Role show(Role role) {
        if (ObjectUtils.isEmpty(role.getId())) {
            role.setId(UUID.randomUUID().toString());
        }
        return role;
    }

    @ApiIgnore
    @ApiOperation("添加角色(忽略)")
    @PostMapping("/add")
    public Role add(Role role) {
        return role;
    }
}
